import app
from flask import request, session, render_template
import socket
import time


# @app.teardown_request
# def teardown_request(erorr):
#     print("服务器出现异常%s" % erorr)

#
# @app.before_first_request
# def welcome():
#     print("网站正式成立")
#
#
# @app.before_request
# def before_request():
#     userAg = str(request.user_agent)
#     if not userAg.__contains__("Windows"):
#         print("非windows操作系统，拒绝访问")
#     # 验证是否已登录，
#     if not session.get("user"):
#         return render_template("login.html")
#
#
#
# @app.after_request
# def record(response):
#     userAg = request.user_agent
#     # 获取本机计算机名称
#     hostname = socket.gethostname()
#     # 获取本机ip
#     ip = socket.gethostbyname(hostname)
#     # 记录请求设备 系统型号，ip，请求时间
#     t = time.strftime("%Y-%m-%d, %H:%M:%S")
#     d = {"ip地址": ip, "终端型号": userAg.string, "请求时间": t}
#     with open("gvuuvpApp.txt", "a+", encoding="utf-8") as f:
#         f.write(str(d) + "\n")
#     return response
